package com.fubowen.lepton.helper

import android.content.Context
import android.util.Log
import java.io.InputStream
import java.util.Properties

object AppConfigHelper {

    private lateinit var properties: Properties

    fun init(context: Context) {
        properties = Properties()
        var input: InputStream? = null
        try {
            input = context.resources.assets.open("AppConfig.properties")
            properties.load(input)
        } catch (e: Exception) {
            Log.e("AppConfig.properties", "无法读取程序的配置文件")
        } finally {
            input?.close()
        }
    }

    fun get(key: String?): String? {
        return properties.getProperty(key)
    }

    fun set(key: String, value: String?) {
        properties.setProperty(key, value)
    }
}